<template>
    <div class="content">
        <div class="clearfix">
            <Form class="f-fl" inline :label-width="5">
                <FormItem>
                    <Input
                        v-model="params.name"
                        placeholder="实训名称"
                    ></Input>
                </FormItem>
                <FormItem>
                    <Button type="primary" @click="queryList">搜索</Button>
                </FormItem>
                <FormItem>
                    <Button @click="clearSearch">清空</Button>
                </FormItem>
            </Form>

        </div>
        <Table :data="list" :columns="columns" border align="center">
            <template slot-scope="{ row }" slot="startTime">
                <span>{{row.startTime}} - {{row.endTime}}</span>

            </template>
            <template slot-scope="{ row }" slot="action">
                <div class="table-action">
                    <Button type="text" @click="ckTrain(row)">查看实训</Button>
                </div>
            </template>
        </Table>
        <Pagination
            :pageSize.sync="params.pageSize"
            :current.sync="params.pageNum"
            :total="params.total"
            @change="queryList"
        />
    </div>
</template>
<script>
import { trainList } from '@/api/studentExam'
export default {
    inject: ['nextPageReload'],
    data () {
        return {
            roleType: '',
            schoolList: [],
            params: {
                name: '',
                pageNum: 1,
                pageSize: 10,
                total: 0
            },
            list: [],
            columns: Object.freeze([
                { title: '序号', type: 'index', align: 'center', width: 80 },
                { title: '实训名称', key: 'name', align: 'center', width: 200 },
                { title: '实训类型', key: 'type', align: 'center', width: 200 },
                { title: '实训案例', key: 'caseId', align: 'center', width: 200 },
                { title: '实训时间', slot: 'startTime', align: 'center' },
                { title: '实训得分', key: 'practicalScore', align: 'center' },
                { title: '操作', slot: 'action', align: 'center', width: 160 }
            ])
        }
    },
    mounted () {
        this.queryList()
    },
    methods: {
        search () {
            this.params.pageNum = 1
            this.queryList()
        },
        ckTrain (row) {
            this.$router.push({
                path: `/training/${row.id}`
            })
        },
        queryList () {
            let params = {

                pageNum: this.params.pageNum,
                pageSize: this.params.pageSize,
                name: this.params.name
            }
            trainList(params).then(res => {
                this.list = res.data.data.list
            })
        }
    }
}
</script>
